<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;

class ShareController extends Controller
{
    public function setSession(Request $request)
    {
        //通过put方法
        $request->session()->put('key', 'value');

        //通过全局辅助函数
        session(['key2' => 'value2']);
    }

    public function getSession(Request $request)
    {
//        if(!session_id())
//        {
//            session_start();
//        }
//        $_SESSION['test'] = '123213';
//        echo 'id = '.session_id().'<br/>';
//        var_dump($_SESSION);


        $session_id = Session::getId();
        echo 'id = '.$session_id;

        session([
            'test' => '222',
            'user' => 'wenqing2'
        ]);

        dump($request->session()->all());

//        $session_id = $_COOKIE["laravel_session"];
//        echo 's = '.$session_id;
    }

    public function session_all(Request $request)
    {
        $request->session()->put('test3','3333');
    }
}
